I'm writing Chrome extension that saves some files using chrome.downloads.download method. I call it from my background.js and it works fine unless "Ask where to save each file before downloading" option of browser is enabled or saveAs option is true.
This is background.js which reproduces this problem:
chrome.downloads.download({
url: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png',
saveAs: false
}, (itemId) => {
chrome.downloads.onChanged.addListener((delta) => {
if (itemId === delta.id) {
console.log(delta)
}
})
})
It downloads google logo when saveAs is false. In console i can see events first with status in_progress then with status complete. But if i set saveAs to true, there will be event with status iterrupted and error USER_CANCELED. Chrome doesn't open "Save as" dialog for some reason i don't understand, even if "Ask where to save each file before downloading" is enabled. More to it if "Ask where to save each file before downloading" is enabled download will be interrupted regardless of the saveAs value.
Chrome documentation describes saveAs option: "Use a file-chooser to allow the user to select a filename regardless of whether filename is set or already exists". But for me it doesn't work regardless of the value of filename option. Am i missing something?
The Chrome version is the last as of today (Version 102.0.5005.115 (Official Build) (64-bit)) and manifest version is 3.